//
//  CZQAddCerView.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/14.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "CZQAddCerView.h"

@implementation CZQAddCerView
-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIScrollView *scrollView = [[UIScrollView alloc] init];
        [self addSubview:scrollView];
        
        scrollView.backgroundColor = CSWhiteColor;
        
        self.scrollView = scrollView;
        
        
        
        /**
         机构名称
         */
        CommonInputView *companyInputView = [[CommonInputView alloc] init];
        companyInputView.titleLabel.text = @"机构名称*";
        companyInputView.titleTF.placeholder = @"机构名称";
        [scrollView addSubview:companyInputView];
        self.companyView = companyInputView;
        
        /**
         证书名称
         */
        CommonInputView *jobNameInputView = [[CommonInputView alloc] init];
        jobNameInputView.titleLabel.text = @"证书名称*";
        jobNameInputView.titleTF.placeholder = @"证书名称";
        [scrollView addSubview:jobNameInputView];
        self.cerNameView = jobNameInputView;
        
        /**
         上传证书/图片
         */
        CommonInputView *jobTitleInputView = [[CommonInputView alloc] init];
        jobTitleInputView.titleLabel.text = @"上传证书/图片";
        jobTitleInputView.titleTF.placeholder = @"";
        jobTitleInputView.lineView.hidden = YES;
        jobTitleInputView.titleTF.userInteractionEnabled = NO;
        [scrollView addSubview:jobTitleInputView];
        self.upLoadCerView = jobTitleInputView;
        
        /**
         起始时间
         */
        CommonBtnView *startBtnView = [[CommonBtnView alloc] init];
        startBtnView.titleLabel.text = @"生效时间*";
        startBtnView.choseLabel.text = @"选择生效时间";
        startBtnView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:startBtnView];
        self.startTimeBtnView = startBtnView;
        
        /**
         结束时间
         */
        CommonBtnView *endBtnView = [[CommonBtnView alloc] init];
        endBtnView.titleLabel.text = @"失效时间*";
        endBtnView.choseLabel.text = @"选择失效时间";
        endBtnView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:endBtnView];
        self.endTimeBtnView = endBtnView;
        
        //图片
        UIButton *cerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [cerBtn setImage:PlaceHold forState:UIControlStateNormal];
        
        self.cerPhotoBtn = cerBtn ;
        
        [self.scrollView addSubview:cerBtn];
        
        
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(self);
    }];
    
    
    //公司名称
    [self.companyView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self);
        
        make.left.width.mas_equalTo(self);
    }];
    
    //工作岗位
    [self.cerNameView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.companyView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
    }];
    
    //起始时间
    [self.startTimeBtnView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.cerNameView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
    }];
    
    //结束时间
    [self.endTimeBtnView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.startTimeBtnView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
    }];
    
    //上传图片
    [self.upLoadCerView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.endTimeBtnView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
    }];
    
    [self.cerPhotoBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.upLoadCerView.mas_bottom);
        
        make.left.mas_equalTo(self).offset(20);
        
        make.height.width.mas_equalTo(80);
    }];
    
    
    
}

-(void)layoutSubviews{
    
    self.scrollView.contentSize = CGSizeMake(self.width, self.cerPhotoBtn.bottom + CZQ_StatusBarHeight + CZQ_NavigationBarHeight);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
